package com.itcam;

import com.itcam.dynamic.ProxyFactory;
import com.itcam.statics.StaticProxyCaculator;

/**
 * Author:Cammy.Wu
 * Date:2024-04-25
 * Description:
 */

public class UserAop {

    public static void main(String[] args) {
        // 目标（房东）
        Calculator target =new CalculatorPureImpl();

        // 代理（中介
        StaticProxyCaculator proxy = new StaticProxyCaculator(target);

        // 调用
        int add = proxy.add(5,9);
        System.out.println("add = " + add);

        // jdk代理
        ProxyFactory proxyFactory = new ProxyFactory(target);
        // 使用接口接值 = 代理对象【兄弟、拜把子】
        Calculator proxy1 = (Calculator) proxyFactory.getProxy();
        proxy1.add(5,7);

    }
}
